let vm = new Vue({
    el:'.main-container',  //选中整个main
    data:{
        page:{}, //初始化对象     vue建议声明对象同时进行初始化，避免undefinded
        type:'',
        config:{
            UEDITOR_HOME_URL:'static/ueditor/',//富文本的加载路径拼接
            maximumWords:100000,    //富文本最多的字数
            serverUrl: 'doUeditor/'
        },
        statutes:{

        },
        isActive:true
    },
    methods: {
        selectPage:function (start=1,pageSize=5) {
            //this.page={};
            // console.log(this.configurations);
            axios({
                url:`/guguanjia/manager/statute/selectPage/${start}/${pageSize}`,   //相对路径同样受到base标签影响
                params:{type:this.type}
            }).then(
                response=>{  //省略function关键字  自动传递上下文中的this
                    //this.apps = response.data.obj.list;
                    this.page = response.data.obj;
                    // console.log(this.page)
                }
            ).catch(error=>{
                console.log(error.message);
            })
        },
        selectAll:function(){
            this.type='';
            this.selectPage();
        },
        toUpdate:function (state) {
            layer.obj = state;
            layer.open({
                type: 2,
                title: '更新',
                maxmin: true,
                shadeClose: true, //点击遮罩关闭层
                area : ['1800px' , '700px'],
                content: 'statute/update.html',
                end: ()=>{
                    // layer.msg("更新完成")
                    this.selectAll();//刷新页面
                }
            });
        },
        insertStatute:function () {
            //this.page={};
            console.log(this.configurations);
            axios.post(`/guguanjia//manager/statute/insertStatute`,this.statutes).then(
                response=>{  //省略function关键字  自动传递上下文中的this
                    //切换前先清空数据
                    this.statutes={};
                    //插入成功，切换到列表页面
                    this.isActive=!this.isActive;
                }
            ).catch(error=>{
                console.log(error.message);
            })
        },
        changeShow:function () {
            this.isActive=!this.isActive;
            // alert(this.isActive);
        },
        deleteAppVersionById:function (statute) {
            layer.confirm('确认是否要删除？', {
                btn: ['是','否'] //按钮
            }, ()=>{
                axios.put(`/guguanjia//manager/statute/deleteAppVersionById`,statute).then(
                    (result)=>{
                        if (result.data.success){
                            layer.msg("删除成功");
                            this.selectAll();
                        }else {
                            layer.msg("删除失败");
                        }
                    }
                ).catch((error)=>{
                    layer.msg("删除失败");
                })
            }, function(){
                layer.msg("取消")
            });
        }
    },
    created:function () {
        this.selectAll();
        // console.log(this.page);
    },
    mounted:function(){
        jeDate({
            dateCell: '#indate',
            format: 'YYYY-MM-DD',
            zIndex: 999999999,
            choosefun:(val)=> {
                this.statutes.pubDate=val;
            }
        });
    },
    components:{
        VueUeditorWrap  //富文本组件
    }
});